/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once


#include <基本类型.h>
#include "引擎枚举数据.h"


#define DEF_按键状态_准备	0
#define DEF_按键状态_按下	1
#define DEF_按键状态_按下中	2
#define DEF_按键状态_放开	4


typedef enum : uint8 {
	e_按下,
	e_放开,
	e_点击,
}E_Key姿态类型;

enum E_Input_鼠标按键 : uint8 {
	e_左键,
	e_右键,
	e_中键,
	
	e_滚轮,
	e_X轴,
	e_Y轴,
	e_扩展按键1,
	e_扩展按键2,
	e_扩展按键3,
	e_扩展按键4,
};

enum class E_平台键值类型 : uint8 {
	e_Dx8,
	e_Win,
};

struct S_InputKey {
	static uint8 e_ESC;


	static uint8 e_KEY_1;
	static uint8 e_KEY_2;
	static uint8 e_KEY_3;
	static uint8 e_KEY_4;
	static uint8 e_KEY_5;
	static uint8 e_KEY_6;
	static uint8 e_KEY_7;
	static uint8 e_KEY_8;
	static uint8 e_KEY_9;
	static uint8 e_KEY_0;
	

	static uint8 e_KEY_空格;
	static uint8 e_KEY_退格;
	static uint8 e_KEY_TAB;

	
	static uint8 e_KEY_A;
	static uint8 e_KEY_B;
	static uint8 e_KEY_C;
	static uint8 e_KEY_D;
	static uint8 e_KEY_E;
	static uint8 e_KEY_F;
	static uint8 e_KEY_G;
	static uint8 e_KEY_H;
	static uint8 e_KEY_I;
	static uint8 e_KEY_J;
	static uint8 e_KEY_K;
	static uint8 e_KEY_L;
	static uint8 e_KEY_M;
	static uint8 e_KEY_N;
	static uint8 e_KEY_O;
	static uint8 e_KEY_P;
	static uint8 e_KEY_Q;
	static uint8 e_KEY_R;
	static uint8 e_KEY_S;
	static uint8 e_KEY_T;
	static uint8 e_KEY_U;
	static uint8 e_KEY_V;
	static uint8 e_KEY_W;
	static uint8 e_KEY_X;
	static uint8 e_KEY_Y;
	static uint8 e_KEY_Z;
	

	static uint8 e_KEY_方括号左;
	static uint8 e_KEY_方括号右;
	static uint8 e_KEY_分号;
	static uint8 e_KEY_引号;

	static uint8 e_KEY_点;
	static uint8 e_KEY_回车;
	


	static uint8 e_KEY_F1;
	static uint8 e_KEY_F2;
	static uint8 e_KEY_F3;
	static uint8 e_KEY_F4;
	static uint8 e_KEY_F5;
	static uint8 e_KEY_F6;
	static uint8 e_KEY_F7;
	static uint8 e_KEY_F8;
	static uint8 e_KEY_F9;
	static uint8 e_KEY_F10;
	static uint8 e_KEY_F11;
	static uint8 e_KEY_F12;



	static uint8 e_KEY_减;
	static uint8 e_KEY_加;
	static uint8 e_KEY_斜杠;

	static uint8 e_KEY_BACKQUOTE;
	static uint8 e_KEY_逗号;
	static uint8 e_KEY_句号;
	static uint8 e_KEY_反斜杠;
	static uint8 e_KEY_方向_右;
	static uint8 e_KEY_方向_左;
	static uint8 e_KEY_方向_下;
	static uint8 e_KEY_方向_上;

	static uint8 e_KEY_小键盘数字键_除;
	static uint8 e_KEY_小键盘数字键_乘;
	static uint8 e_KEY_小键盘数字键_减;
	static uint8 e_KEY_小键盘数字键_加;
	static uint8 e_KEY_小键盘数字键_回车;

	static uint8 e_KEY_小键盘数字键_1;
	static uint8 e_KEY_小键盘数字键_2;
	static uint8 e_KEY_小键盘数字键_3;
	static uint8 e_KEY_小键盘数字键_4;
	static uint8 e_KEY_小键盘数字键_5;
	static uint8 e_KEY_小键盘数字键_6;
	static uint8 e_KEY_小键盘数字键_7;
	static uint8 e_KEY_小键盘数字键_8;
	static uint8 e_KEY_小键盘数字键_9;
	static uint8 e_KEY_小键盘数字键_0;
	static uint8 e_KEY_小键盘数字键_点;


	static uint8 e_KEY_大写锁定;
	static uint8 e_KEY_左SHIFT;
	static uint8 e_KEY_左CTRL;
	static uint8 e_KEY_左ALT;
	static uint8 e_KEY_右SHIFT;
	static uint8 e_KEY_右CTRL;
	static uint8 e_KEY_右ALT;


	static uint8 e_KEY_上一页;
	static uint8 e_KEY_下一页;
	static uint8 e_KEY_删除;



	static uint8 e_KEY_左系统徽标;
	static uint8 e_KEY_右系统徽标;
	static uint8 e_KEY_菜单;

private:

};




typedef struct {
	S_结构指针	m_鼠标设备;
	S_结构指针	m_键盘设备;
	S_结构指针	m_鼠标;
	//S_结构对象指针	m_鼠标;
	ivec2		m_鼠标全局坐标;

	S_键盘		m_Key;

	bool		m_设备是否激活;
	void*		m_InputDev;
	//int32		m_键盘按键按下数量;
}S_输入环境;





EngineAPI_EXPORT S_输入环境*	f_input_create输入设备();
EngineAPI_EXPORT void			f_input_release输入设备(S_输入环境* 设备);


EngineAPI_EXPORT void f_initInput(S_输入环境* ctx, S_结构指针 窗口勾丙, S_结构指针 窗口实例);

EngineAPI_EXPORT void f_input_取输入状态(S_输入环境* ctx);


EngineAPI_EXPORT uint8	f_getKeyDown(const S_键盘& ctx);
EngineAPI_EXPORT uint8	f_getKeyUn(const S_键盘& ctx);

EngineAPI_EXPORT uint16			f_input_getDXAsciiKey(uint8 key, E_平台键值类型 类型 = E_平台键值类型::e_Dx8);
EngineAPI_EXPORT std::u16string	f_input_getDX键码名称(uint8 key);
EngineAPI_EXPORT int16			f_input_getDX按键小键盘值(int8 key);



inline uint8 f_Key(const S_键盘& keys, uint8 i) {
	return keys.Keys[i];
}
//键盘键码按键状态
inline uint8 f_KS(const S_键盘& keys, uint8 i) {
	return keys.Keys状态[i];
}


inline bool f_input_数值输入(uint8 key) {
	return key >= 32 && key < 64;
}





typedef struct {
	uint8*	m_RKsy;
	uint8*	m_RCKey;
	uint8	m_KNum;
	uint8	m_CKNum;
}S_注册快捷键;

EngineAPI_EXPORT bool f_input_打开设备();
EngineAPI_EXPORT void f_input_关闭设备();

EngineAPI_EXPORT float32*	f_input_get脑波数据(uint32& 通道数量);
EngineAPI_EXPORT void		f_input_get脑波数据(std::vector<float32>& data, uint32 要取得的数量);


